package com.emergency.embackend.exception;

import com.emergency.embackend.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author chddd
 * @description
 * @create 2024/1/19 9:31:54
 */
@Slf4j
@RestControllerAdvice
public class ExceptionControllerAdvice {
    @ExceptionHandler(EmException.class)
    public R handlerException(EmException e){
        log.error(e.toString(), e);
        return R.exception(e.getMsg());
    }
    @ExceptionHandler(RuntimeException.class)
    public R handleRuntimeException(RuntimeException e) {
        log.error(e.toString(), e);
        return R.exception(e.getMessage());
    }
}
